#pragma once
#include "base/core/singleton.h"
#include "Common/MessageDispatch/IMessageDispatch.h"
#include <unordered_map>
#include "ProtoBuffer/AllProtocol.h"
#include "Common/CharacterDefine.h"

class GmMgr : public ManualSingleton<GmMgr>,
		public IClientMessageHandler,
		public IServerMessageHandler
{
	friend class ManualSingleton<GmMgr>;
	typedef bool(GmMgr::*pGmCmdFunc)(CharIDType cid, vector<std::string> &args);
	typedef unordered_map<string, pGmCmdFunc> GmFunc;

protected:
	GmFunc m_gmFunc;
public:
	bool Init();
	bool UnInit();

	virtual void		onClientMessage(uint32_t actionId, RECV_PACKAGE& package, uint64_t Id = 0);
	virtual const char* getClientHandlerDebugInfo(void){ return "GmMgr::onClientMessage"; }

	virtual void		onServerMessage(uint32_t actionId, RECV_PACKAGE &package);
	virtual const char* getServerHandlerDebugInfo(void) { return nullptr; };

	GmMgr();
	virtual ~GmMgr();
public:
	bool OnHangleMsg(CharIDType Id, LogicGM & gm, bool fromWeb = false);
public: //处理函数
	bool OnCharacterLevelUp(CharIDType cid, vector<std::string> &args);
	bool OnCharacterGotoPos(CharIDType cid, vector<std::string> &args);
	bool OnCharacterGotoMap(CharIDType cid, vector<std::string> &args);
	bool OnCharacterAddGold(CharIDType cid, vector<std::string> &args);
	bool OnCharacterAddDiamond(CharIDType cid, vector<std::string> &args);
	bool OnGetBindDiamond(CharIDType cid, vector<std::string> &args);
	bool OnCharacterAddAttr(CharIDType cid, vector<std::string> &args);
	bool SetCollectSkill(CharIDType cid, vector<std::string> &args);
	bool SetMakeSkill(CharIDType cid, vector<std::string> &args);
	bool AddCollectEnergy(CharIDType cid, vector<std::string> &args);
	bool AddMakeEnergy(CharIDType cid, vector<std::string> &args);
	bool AddStateBag(CharIDType cid, vector<std::string> &args);
	bool AddMonster(CharIDType cid, vector<std::string> &args);
	bool AIOn(CharIDType cid, vector<std::string> &args);
	bool AIOff(CharIDType cid, vector<std::string> &args);
	bool Suicide(CharIDType cid, vector<std::string> &args);
	bool Invincible(CharIDType cid, vector<std::string> &args);
	bool GetItem(CharIDType cid, vector<std::string> &args);
	bool AddRobot(CharIDType cid, vector<std::string> &args);
	bool SetTime(CharIDType cid, vector<std::string> &args);
	bool StartPlane(CharIDType cid, vector<std::string> &args);
	bool StopPlane(CharIDType cid, vector<std::string> &args);
	bool ReceiveMission(CharIDType cid, vector<std::string> &args);
	bool FinishMission(CharIDType cid, vector<std::string> &args);
	bool SigleFinishMission(CharIDType cid, vector<std::string> &args);
	bool EndMission(CharIDType cid, vector<std::string> &args);
	bool OnTrigger(CharIDType cid, vector<std::string> &args);
	bool OnUseSkill(CharIDType cid, vector<std::string> &args);
	bool OnMaoGoTo(CharIDType cid, vector<std::string> &args);
	bool SetTreasureArea(CharIDType cid, vector<std::string> &args);
	bool OnAddPKValue(CharIDType cid, vector<std::string> &args);
	bool ClearPackage(CharIDType cid, vector<std::string> &args);
	bool RemoveMission(CharIDType cid, vector<std::string> &args);
	bool SetHuoYue(CharIDType cid, vector<std::string> &args);
};

#define g_MakeGmMgr() (GmMgr::Instance())
#define g_GetGmMgr()  (GmMgr::GetInstance())
#define g_DelGmMgr()  (GmMgr::Destroy())
